home *** CD-ROM | disk | FTP | other *** search
/ Power Bytes: Money & Finance / PowerBytes Money and Finance CD-ROM 01 / PowerBytes Money and Finance CD-ROM 01.iso / Utilities / Program Utils. / MEdit ƒ / Macros.mcr next >
Encoding:
Text File  |  1986-04-03  |  4.5 KB  |  221 lines  |  [TEXT/MEDT]

  1. **************************************************************************
  2. * This macro file is provided as a collection of useful example macros   *
  3. * You need MEdit version 1.2 or later to load this file.                 *
  4. * IMPORTANT: TO SPEED UP LOADING REMOVE ALL COMMENTS (lines starting     *
  5. *            with an asterik)                                            *
  6. * Written           : 05.01.86 Matthias Aebi                             *
  7. * Last modification : 31.03.86 Matthias Aebi                             *
  8. **************************************************************************
  9.  
  10. * 1
  11. * this macro can be used to get irregulary spaced tabs.
  12. * write a dot in the first line of the window for every tab stop
  13. * that you would like to use
  14. "Tabs" {
  15.     Push;
  16.     Select(0,C.);
  17.     Push;
  18.     Find(".");
  19.     Select(0,C[ | 0,C.);
  20.     Copy;
  21.     Drop;
  22.     Pop;
  23.     Paste;
  24.     Insert(" ");
  25. };
  26.  
  27. * for use together with the following macros
  28. * 2
  29. "Save current Position/P" {
  30.     push;
  31. };
  32.  
  33. * 3
  34. * jumps back to the last saved position with macro 2
  35. * the stack can hold the last eight positions
  36. "Back to Position/B" {
  37.     select(L[,C[)!;
  38.     pop;
  39. };
  40.  
  41. * 4
  42. * moves the current selection to the position / selection
  43. * previously saved with macro 2
  44. "Move selection/M" {
  45.     cut;
  46.     pop;
  47.     paste!;
  48. };
  49.  
  50. * 5
  51. * copies the current selection to the position / selection
  52. * previously saved with macro 2
  53. "Copy selection/K" {
  54.     copy;
  55.     pop;
  56.     paste!;
  57. };
  58.  
  59. * 6
  60. * draw a line in the menu
  61. "-" {};
  62.  
  63. * 7
  64. * jump to bottom of file
  65. "Bottom" {
  66.     SELECT(L$,C$)!;
  67. };
  68.  
  69. * 8
  70. * jump to top of file
  71. "Top" {
  72.     SELECT(0,0)!;
  73. };
  74.  
  75. * 9
  76. * select all lines in the file
  77. "Select all" {
  78.     SELECT(0,0|L$,C$);
  79. };
  80.  
  81. * 10
  82. * move all lines in the current selection four positions to the left
  83. * by deleting the leftmost characters. do nothing for empty lines.
  84. "Move selection left/L" {
  85.     PUSH;
  86.     WHILE L. < L] {
  87.         SELECT(L.,0|L.,4);
  88.         CLEAR;
  89.         SELECT(L.+1,0)!;
  90.     };
  91.     SELECT(L[,0|L],0);
  92.     DROP;
  93. };
  94.  
  95. * 11
  96. * move all lines in the current selection to the right by inserting
  97. * a tab. do nothing for empty lines.
  98. "Move selection right/R" {
  99.     PUSH;
  100.     WHILE L. < L] {
  101.  
  102.         SELECT(L.,0);
  103.         IF NOT C$ = 0 {
  104.             INSERT("\t");
  105.         };
  106.         SELECT(L.+1,0)!;
  107.     };
  108.     SELECT(L[,0|L],0);
  109.     DROP;
  110. };
  111.  
  112. * 12
  113. * ask for a line number to jump to and do it
  114. "Jump to Line/J" {
  115.     prompt("Goto Line",#0);
  116.     select(#0-1,0|#0-1,C$)!;
  117. };
  118.  
  119. * 13
  120. * replace the shortcut to the left of the cursor position with
  121. * the appropriate string. to define shortcuts write them at the
  122. * top of the window followed by the string to insert. use one line for
  123. * each shortcut. separate string and shortcut by a blank.
  124. * examples: (define them without an asterik at the start of the window)
  125. * ilm I like Macintosh
  126. * gb Good bye
  127. *
  128. * if you type 'ilm' and then press command-g this will replace
  129. * 'ilm' with 'I like Macintosh'. 'gb' will be replaced by 'Good bye'
  130. "Glossary/G" {
  131.     Select(L.,C<|L.,C.);
  132.     Push;
  133.     Set($0,$S);
  134.     Select(0,0);
  135.     Find($0);
  136.  
  137.     If L. < L[ And C. = 0{
  138.         Select(L.,C:+1|L.,C$);
  139.         Copy;
  140.         Pop;
  141.         Paste;
  142.     }
  143.     Else {
  144.         Pop;
  145.         Select(L:,C:);
  146.     };
  147. };
  148.  
  149. * 14
  150. * scroll one screen down
  151. * if you have a Mac+ or a numeric keypad you may use shift-cursor-down
  152. "Page Down/D" 272 {
  153. * get screen height
  154.     Set(#9, L>-L<-1);
  155.     Select(L>+#9,C.)!;
  156. };
  157.  
  158. * 15
  159. * scroll one screen up
  160. * if you have a Mac+ or a numeric keypad you may use shift-cursor-up
  161. "Page Up/U" 277 {
  162. * get screen height
  163.     Set(#9, L>-L<-1);
  164.     Select(L<-#9,C.)!;
  165. };
  166.  
  167. * 16
  168. * replace all 'real' tabs by blank strings
  169. * this is useful to convert 'Edit'- to 'MEdit'-files
  170. "Replace tabs" {
  171.     SELECT(0,0)!;
  172.     FIND("\9");
  173.     WHILE NOT L. = 0 OR NOT C. = 0 {
  174.         INSERT("\t");
  175.         FIND("\9");
  176.     };
  177. };
  178.  
  179. "-" {};
  180.  
  181. * the numbers define cursor keys on a Mac Plus / num Keypad
  182. "Cursor Up/2" 177 {
  183.     SELECT(L.-1,C.)!;
  184. };
  185.  
  186. "Cursor Down/A" 172 {
  187.     SELECT(L.+1,C.)!;
  188. };
  189.  
  190. "Cursor Right/W" 166 {
  191.     SELECT(L.,C.+1)!;
  192.     IF C. = C$ {
  193.         SELECT(L.+1,0)!;
  194.     };
  195. };
  196.  
  197. "Cursor Left/Q" 170 {
  198.     SELECT(L.,C.-1)!;
  199.     IF C. = 0 {
  200.         SELECT(L.-1,0);
  201.         SELECT(L.,C$);
  202.     };
  203. };
  204.  
  205. * this macro could be used to
  206. * redefinie shift-BS to 'delete to end of line' instead of 'delete right char'
  207. *251 {
  208. *    Select(L.,C.|L.,C$);
  209. *    Clear;
  210. *};
  211.  
  212. * swaps the to characters just before the current position
  213. * this macro is invoked by pressing option-BS. It has no menu entry
  214. 351 {
  215.     SELECT(L.,C.-1|L.,C.);
  216.     CUT;
  217.     SELECT(L.,C.-1);
  218.     PASTE;
  219.     SELECT(L.,C.+1);
  220. }.
  221.